<template>
  <div
    id="app"
    v-loading="loading"
    :element-loading-text="title"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.7)"
  >
    <MainBox></MainBox>
  </div>
</template>

<script>
import { mapState } from "vuex";
import MainBox from "./views/index.vue";
export default {
  name: "App",
  components: {
    MainBox,
  },
  data(){
    return {
    }
  },
  computed: {
    ...mapState("app", ["loading","title"]),
  },
  created() {
    //在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem("store")) {
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
    }
    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener("beforeunload", () => {
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    });
  },
  methods: {},
};
</script>

<style  lang="less" >
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
  list-style: none;
}
// html{
//   font-size:16px;
// }

box {
  width: 10rem;
  height: 10rem;
  background-color: pink;
  margin-left: 20rem;
}
.el-loading-spinner .el-icon-loading,
.el-loading-text{
  color:rgb(36, 165, 116) !important;
  font-size:18px !important;
}
.el-icon-loading:before{
  font-size:25px !important;
}
</style>
